jun.MtPinjamanWin = Ext.extend(Ext.Window, {title: "Peminjaman Kendaraan", modez: 1, id: "mt-win-pinjam", width: 900, height: 570, layout: "form", modal: !0, padding: 5, closeForm: !1, resizable: !1, iswin: !0, initComponent: function () {
    this.items = [
        {xtype: "form", frame: !1, bodyStyle: "background-color: #E4E4E4; padding: 10px", id: "from-MtPinjamanWin", labelWidth: 100, labelAlign: "left", layout: "absolute", ref: "formz", anchor: "100% 100%", border: !1, items: [
            {xtype: "label", text: "No.Pinjam", x: 5, y: 5},
            {xtype: "textfield", hideLabel: !1, name: "doc_ref", id: "doc_refid", readOnly: !0, ref: "../doc_ref", x: 100, y: 2, height: 20, width: 200},
            {xtype: "label", text: "Nama Konsumen", x: 5, y: 35},
            {xtype: "combo", typeAhead: !0, triggerAction: "all", lazyRender: !0, mode: "local", allowBlank: !1, forceSelection: !0, lastQuery: "", store: jun.rztMtPelanggan, hiddenName: "id_pelanggan", hiddenValue: "id_pelanggan", valueField: "id_pelanggan", displayField: "nama", x: 100, y: 32, height: 20, width: 200},
            {xtype: "label", text: "Tanda Pengenal", x: 5, y: 65},
            new jun.comboTandaPengenal({allowBlank: !1, value: "KTP", name: "tanda_pengenal", x: 100, y: 62, height: 20, width: 200}),
            {xtype: "label", text: "Tanggal Transaksi", x: 540, y: 5},
            {xtype: "xdatefield", ref: "../trans_date", fieldLabel: "trans_date", name: "trans_date", id: "trans_dateid", format: "d M Y", allowBlank: !1, x: 660, y: 2, height: 20, width: 200},
            {xtype: "label", text: "Kelompok Konsumen", x: 540, y: 35},
            {xtype: "combo", typeAhead: !0, triggerAction: "all", lazyRender: !0, mode: "local", allowBlank: !1, forceSelection: !0, store: jun.rztMtKelompokPelanggan, hiddenName: "id_kelompok", hiddenValue: "id_kelompok", valueField: "id_kelompok", displayField: "nama", ref: "../id_kelompok", lastQuery: "", x: 660, y: 32, height: 20, width: 200},
            {xtype: "label", text: "No Identitas", x: 540, y: 65},
            {xtype: "textfield", hideLabel: !1, allowBlank: !1, name: "no_identitas", id: "no_identitasid", ref: "../no_identitas", maxLength: 30, x: 660, y: 62, height: 20, width: 200},
            {xtype: "label", text: "Jaminan:", x: 5, y: 95},
            new jun.cmbJaminan({allowBlank: !1, value: "Kartu Keluarga", name: "jaminan", x: 100, y: 92, height: 20, width: 200}),
            {xtype: "textarea", name: "jaminan_desc", id: "jaminan_descid", ref: "../jaminan_desc", maxLength: 90, allowBlank: !1, height: "70", width: "400", x: 100, y: 122},
            {xtype: "label", text: "Season", x: 540, y: 95},
            new jun.cmbSeason({name: "season", ref: "../season", allowBlank: !1, x: 660, y: 92, height: 20, width: 200}),
            {xtype: "label", text: "Tanggal Pinjam", x: 5, y: 215},
            {xtype: "xdatefield", ref: "../tgl_pinjam", name: "tgl_pinjam", id: "tgl_pinjamid", format: "d M Y H:i", submitFormat: "Y-m-d H:i", allowBlank: !1, x: 100, y: 212, height: 20, width: 200},
            {xtype: "label", text: "Lama Sewa", x: 340, y: 215},
            {xtype: "spinnerfield", hideLabel: !1, name: "sewa_bln", id: "sewa_blnid", ref: "../sewa_bln", maxLength: 2, minValue: 0, maxValue: 12, value: 0, allowBlank: !1, x: 410, y: 212, height: 20, width: 50},
            {xtype: "label", text: "(bulan)", x: 470, y: 215},
            {xtype: "spinnerfield", hideLabel: !1, name: "sewa_hari", id: "sewa_hariid", ref: "../sewa_hari", maxLength: 2, minValue: 0, maxValue: 31, value: 0, allowBlank: !1, x: 520, y: 212, height: 20, width: 50},
            {xtype: "label", text: "(hari)", x: 580, y: 215},
            {xtype: "spinnerfield", hideLabel: !1, name: "sewa_jam", id: "sewa_jamid", ref: "../sewa_jam", maxLength: 2, minValue: 0, maxValue: 12, value: 0, incrementValue: 12, allowBlank: !1, x: 620, y: 212, height: 20, width: 50},
            {xtype: "label", text: "(jam)", x: 680, y: 215},
            {xtype: "label", text: "Rencana Kembali", x: 5, y: 245},
            {xtype: "xdatefield", hideLabel: !1, format: "d M Y H:i", submitFormat: "Y-m-d H:i", name: "tgl_rencana_kembali", id: "tgl_rencana_kembali", maxLength: 40, readOnly: !0, ref: "../rencana_tanggal_kembali", x: 100, y: 242, height: 20, width: 200},
            {xtype: "label", text: "ONGKOS SEWA", x: 5, y: 275},
            {xtype: "label", text: "Nama Driver", x: 5, y: 305},
            {xtype: "combo", typeAhead: !0, triggerAction: "all", lazyRender: !0, mode: "local", forceSelection: !0, lastQuery: "", store: jun.rztMtDriver, hiddenName: "id_driver", hiddenValue: "id_driver", valueField: "id_driver", displayField: "nama", allowBlank: !0, emptyText: "Non Driver", ref: "../driver", readOnly: !0, x: 100, y: 302, height: 20, width: 100},
            {xtype: "label", text: "No Polisi", x: 5, y: 335},
            {xtype: "combo", typeAhead: !0, triggerAction: "all", lazyRender: !0, mode: "local", allowBlank: !1, forceSelection: !0, lastQuery: "", store: jun.rztMtMobil, hiddenName: "id_mobil", hiddenValue: "id_mobil", valueField: "id_mobil", displayField: "nopol", ref: "../nopol", x: 100, y: 332, height: 20, width: 100},
            {xtype: "label", text: "Jenis Mobil", x: 210, y: 335},
            {xtype: "textfield", hideLabel: !1, name: "nopolisi", id: "nopolisi", readOnly: !0, ref: "../jenis_mobil", x: 280, y: 332, height: 20, width: 200},
            {xtype: "label", text: "Cara Bayar", x: 5, y: 365},
            new jun.comboPayment({fieldLabel: "Cara Bayar", value: "Tunai", name: "trans_via", x: 100, y: 362, height: 20, width: 100}),
            {xtype: "label", text: "Bukti Transfer", x: 210, y: 365},
            {xtype: "textfield", hideLabel: !1, name: "no_bukti_bayar", id: "no_bukti_bayarid", ref: "../no_bukti_bayar", maxLength: 50, allowBlank: !1, x: 290, y: 362, height: 20, width: 150},
            {xtype: "label", text: "Ongkos Sewa Mobil", x: 540, y: 245},
            {xtype: "numericfield", hideLabel: !1, name: "ongkos_sewa", id: "ongkos_sewaid", ref: "../ongkos_sewa", maxLength: 30, readOnly: !0, value: 0, x: 660, y: 242, height: 20, width: 200},
            {xtype: "label", text: "Driver", x: 540, y: 275},
            {xtype: "numericfield", hideLabel: !1, name: "ongkos_driver", id: "ongkos_driverid", ref: "../ongkos_driver", maxLength: 30, value: 0, allowBlank: !1, x: 660, y: 272, height: 20, width: 200},
            {xtype: "label", text: "Bensin", x: 540, y: 305},
            {xtype: "numericfield", hideLabel: !1, name: "ongkos_bbm", id: "ongkos_bbmid", ref: "../ongkos_bbm", maxLength: 30, value: 0, allowBlank: !1, readOnly: !0, x: 660, y: 305, height: 20, width: 200},
            {xtype: "label", text: "Total Ongkos Sewa", x: 540, y: 335},
            {xtype: "numericfield", hideLabel: !1, name: "total_ongkos", id: "total_ongkosid", ref: "../total_ongkos", maxLength: 30, readOnly: !0, value: 0, x: 660, y: 332, height: 20, width: 200},
            {xtype: "label", text: "Diskon", x: 540, y: 365},
            {xtype: "numericfield", hideLabel: !1, name: "disc", id: "discid", ref: "../disc", maxLength: 30, readOnly: !0, value: 0, x: 660, y: 362, height: 20, width: 200},
            {xtype: "label", text: "Total Semua", x: 540, y: 395},
            {xtype: "numericfield", hideLabel: !1, name: "total", id: "total", ref: "../total", maxLength: 30, readOnly: !0, value: 0, x: 660, y: 392, height: 20, width: 200},
            {xtype: "label", text: "DP", x: 540, y: 425},
            {xtype: "numericfield", hideLabel: !1, name: "dp", id: "dpid", ref: "../dp", maxLength: 30, value: 0, allowBlank: !1, x: 660, y: 422, height: 20, width: 200},
            {xtype: "label", text: "Sisa Tagihan", x: 540, y: 455},
            {xtype: "numericfield", hideLabel: !1, name: "sisa_tagihan", id: "sisa_tagihanid", ref: "../sisa_tagihan", readOnly: !0, maxLength: 30, value: 0, x: 660, y: 452, height: 20, width: 200},
            {xtype: "hidden", name: "trf_bulan", ref: "../trf_bulan"},
            {xtype: "hidden", name: "trf_hari", ref: "../trf_hari"},
            {xtype: "hidden", name: "trf_jam", ref: "../trf_jam"},
            {xtype: "hidden", name: "trf_over_persen", ref: "../trf_over_persen"}
        ]}
    ], this.fbar = {xtype: "toolbar", items: [
        {xtype: "button", text: "Simpan", hidden: !1, ref: "../btnSave", id: "save"},
        {xtype: "button", text: "Simpan & Tutup", ref: "../btnSaveClose", id: "saveClose"},
        {xtype: "button", text: "Tutup", ref: "../btnCancel"}
    ]}, jun.MtTranferBankWin.superclass.initComponent.call(this), this.on("activate", this.onActivate, this), this.sewa_jam.on("spin", this.onDurationChange, this), this.sewa_hari.on("spin", this.onDurationChange, this), this.sewa_bln.on("spin", this.onDurationChange, this), this.tgl_pinjam.on("select", this.onDurationChange, this), this.btnSaveClose.on("click", this.konfirmSave, this), this.btnSave.on("click", this.konfirmSave, this), this.btnCancel.on("click", this.onbtnCancelclick, this), this.nopol.on("select", this.onNopolChange, this), this.driver.on("change", this.onDriverChange, this), this.ongkos_driver.on("change", this.onDriverChange, this), this.ongkos_bbm.on("change", this.calculateTotal, this), this.dp.on("change", this.calculateTotal, this), this.season.on("select", this.calculateTotal, this), this.id_kelompok.on("select", this.calculateTotal, this)
}, calculateTotal: function () {
    var a = this.nopol.getValue(), b = this.id_kelompok.getValue(), c = this.sewa_bln.getValue(), d = this.sewa_hari.getValue(), e = this.sewa_jam.getValue(), f = parseFloat(this.season.getValue());
    if (a === "" || b === "")return;
    var g = jun.getMobil(a), h = jun.getKelompokPelanggan(b), i = jun.getMtSysPrefs("kelompok_other_rental"), j = h.data.id_kelompok === i.data.value, k = j ? 0 : parseFloat(h.data.discont_persen) * .01, l = j ? parseFloat(g.data.other_tarif_12) : parseFloat(g.data.tarif_12), m = j ? parseFloat(g.data.other_tarif_high_12) : parseFloat(g.data.tarif_high_12), n = j ? parseFloat(g.data.other_tarif_24) : parseFloat(g.data.tarif_24), o = j ? parseFloat(g.data.other_tarif_high_24) : parseFloat(g.data.tarif_high_24), p = j ? parseFloat(g.data.other_tarif_bulanan) : parseFloat(g.data.tarif_bulanan), q = j ? parseFloat(g.data.other_overtime) : parseFloat(g.data.overtime), r = f === 0 ? n : o, s = f === 0 ? l : m;
    this.trf_bulan.setValue(p), this.trf_hari.setValue(r), this.trf_jam.setValue(s), this.trf_over_persen.setValue(r * (q / 100));
    var t = p * parseFloat(c), u = r * parseFloat(d), v = parseFloat(e) > 0 ? s : 0, w = t + u + v;
    this.ongkos_sewa.setValue(w);
    var x = parseFloat(this.ongkos_driver.getValue()), y = parseFloat(this.ongkos_bbm.getValue()), z = w + x + y;
    this.total_ongkos.setValue(z);
    var A = z * k;
    this.disc.setValue(A);
    var B = z - A;
    this.total.setValue(B);
    var C = parseFloat(this.dp.getValue());
    this.sisa_tagihan.setValue(B - C)
}, onDriverChange: function () {
    if (this.driver.getValue() === "" || this.driver.getValue() === null)this.ongkos_driver.setValue(0); else {
        var a = parseFloat(this.ongkos_driver.getValue());
        a < 75e3 && this.ongkos_driver.setValue(75e3)
    }
    this.calculateTotal()
}, onNopolChange: function (a) {
    var b = jun.getMobil(a.value);
    this.jenis_mobil.setValue(b.data.jenis), this.calculateTotal()
}, onDurationChange: function () {
    var a = this.tgl_pinjam.getValue();
    if (a === "")return;
    var b = this.sewa_bln.getValue(), c = this.sewa_hari.getValue(), d = this.sewa_jam.getValue(), e = a.add(Date.MONTH, b).add(Date.DAY, c).add(Date.HOUR, d);
    this.rencana_tanggal_kembali.setValue(e), this.calculateTotal()
}, btnDisabled: function (a) {
    this.btnSave.setDisabled(a), this.btnSaveClose.setDisabled(a)
}, onActivate: function () {
    this.modez === 0 ? (this.btnSave.show(), this.btnSaveClose.show()) : (this.btnSave.hide(), this.btnSaveClose.hide())
}, konfirmSave: function () {
    if (parseFloat(this.sisa_tagihan.getValue()) < 0) {
        Ext.MessageBox.alert("Error", "DP tidak bisa lebih dari total semua!"), this.dp.setValue(0);
        return
    }
    var a = parseFloat(this.dp.getValue());
    a === 0 && Ext.MessageBox.confirm("Konfirmasi", "Apakah anda yakin tidak ada uang muka?", this.saveForm, this), this.saveForm("yes")
}, saveForm: function (a) {
    if (a == "no")return;
    this.btnDisabled(!0);
    var b;
    b = "Mahkotrans/MtPinjamKendaraan/create", Ext.getCmp("from-MtPinjamanWin").getForm().submit({url: b, timeOut: 1e3, scope: this, success: function (a, b) {
        var c = Ext.decode(b.response.responseText);
        if (c.success == 0) {
            Ext.MessageBox.show({title: "Peminjaman Kendaraan", msg: c.msg, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR}), this.btnDisabled(!1);
            return
        }
        Ext.MessageBox.show({title: "Peminjaman Kendaraan", msg: c.msg + "<br /> Ref. Dokumen : " + c.id, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO}), Ext.getCmp("from-MtPinjamanWin").getForm().reset(), jun.rztMtPinjamKendaraan.reload(), this.btnDisabled(!1), this.close()
    }, failure: function (a, b) {
        this.btnDisabled(!1);
        if (b.failureType == "client")return;
        Ext.MessageBox.alert("Error", "Can't Communicate With The Server")
    }})
}, onbtnSaveCloseClick: function () {
    this.closeForm = !0, this.saveForm(!0)
}, onbtnSaveclick: function () {
    this.closeForm = !1, this.saveForm(!1)
}, onbtnCancelclick: function () {
    Ext.getCmp("from-MtPinjamanWin").getForm().reset(), this.close()
}}), jun.MtPinjamVoidWin = Ext.extend(Ext.Window, {title: "Void Peminjaman", modez: 1, width: 300, height: 150, layout: "form", modal: !0, padding: 5, closeForm: !1, initComponent: function () {
    this.items = [
        {xtype: "form", frame: !1, bodyStyle: "background-color: #E4E4E4; padding: 10px", id: "form-MtPinjamVoid", layout: "absolute", ref: "formz", border: !1, anchor: "100% 100%", items: [
            {xtype: "label", text: "Alasan Void : ", x: 5, y: 5, width: 100},
            {xtype: "textarea", fieldLabel: "memo", ref: "../memo", id: "memo_id", name: "memo_", x: 5, y: 25, anchor: "100% 100%"}
        ]}
    ], this.fbar = {xtype: "toolbar", items: [
        {xtype: "button", text: "Proses", ref: "../btnProses"},
        {xtype: "button", text: "Batal", ref: "../btnCancel"}
    ]}, jun.MtPinjamVoidWin.superclass.initComponent.call(this), this.btnProses.on("click", this.onbtnProsesclick, this), this.btnCancel.on("click", this.onbtnCancelclick, this)
}, btnDisabled: function (a) {
    this.btnProses.setDisabled(a)
}, onbtnProsesclick: function () {
    this.btnDisabled(!0);
    var a = Ext.getCmp("form-MtPinjamVoid").getForm();
    Ext.getCmp("form-MtPinjamVoid").getForm().submit({url: "Mahkotrans/mtPinjamKendaraan/delete", params: {id: this.id}, method: "POST", scope: this, timeOut: 1e3, success: function (a, b) {
        var c = Ext.decode(b.response.responseText);
        if (c.success == 0) {
            Ext.MessageBox.show({title: "Pengembalian Kendaraan", msg: c.msg, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR});
            return
        }
        Ext.MessageBox.show({title: "Pengembalian Kendaraan", msg: c.msg, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO}), Ext.getCmp("form-MtPinjamVoid").getForm().reset(), this.btnDisabled(!1), jun.rztMtPinjamKendaraan.reload(), this.close()
    }, failure: function (a, b) {
        this.btnDisabled(!1);
        if (b.failureType == "client")return;
        Ext.MessageBox.alert("error", "could not connect to the database. retry later")
    }})
}, onbtnCancelclick: function () {
    this.close()
}});